<script>

/**
 * Orders Component
 */
export default {
  data() {
    return {
      ordersData: [
        {
          name: "抓取门户资讯",
          creator: "管理员1",
          creatTime: "2021-10-08  10:06",
          category: "资讯",
          environment: "正式",
          num: "6",
          type: "手动配置"
        },{
          name: "抓取招标列表",
          creator: "管理员2",
          creatTime: "2021-10-08  10:06",
          category: "招标",
          environment: "测试",
          num: "2",
          type: "手动配置"
        }
      ],
      totalRows: 100,
      currentPage: 1,
      perPage: 10,
      fields: [
        { key: "name", label: "模板名称" },
        { key: "creator", label: "创建者" },
        { key: "creatTime", label: "创建时间" },
        { key: "category", label: "分类类别" },
        { key: "environment", label: "运行环境" },
        { key: "num", label: "使用数量" },
        { key: "type", label: "模板类型" },
        { key: "viewDetail", label: "查看详情" },
      ],
    };
  },
  watch: {
    "currentPage": {
      handler(){
        console.log("触发更新");
      }
    }
  },
  methods: {
    /**
     * Search the table data with search input
     */
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
    // 种子详情
    seedDetail(row){
      console.log(row);
      this.$router.push('/spider/siteDetail')
    },
  }
};
</script>

<template>
  <div class="card">
    <div class="card-body pt-0">
      <div class="table-responsive">
        <b-table
          class="table-centered"
          :items="ordersData"
          :fields="fields"
          responsive="sm"
          :per-page="perPage"
          :current-page="1"
          thead-class="thead-light"
          @filtered="onFiltered"
        >
          <template v-slot:cell(viewDetail)="row">
            <span @click="seedDetail(row)" style="color:#5664d2;cursor: pointer;">查看</span>
          </template>
        </b-table>
      </div>
      <div class="row">
        <div class="col">
          <div class="dataTables_paginate paging_simple_numbers float-right">
            <ul class="pagination pagination-rounded mb-0">
              <!-- pagination -->
              <b-pagination v-model="currentPage" :total-rows="totalRows" :per-page="perPage"></b-pagination>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.search {
  float: left;
  width: 300px;
}
.butn{
  ::v-deep .btn{
    background-color: #252b3b;
    border-color: #252b3b;
    border-radius: 30px;
    display: flex;
    align-items: center;
  }
  ::v-deep .btn-secondary.focus {
    box-shadow: 0 0 0 0.15rem rgb(37 40 58 / 50%);
  }
}
.search-box{
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-centered{
  ::v-deep thead,::v-deep tbody{
    tr{
      th:last-child,td:last-child{
        text-align: right;
      }
    }
  }
}
</style>

